import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

void main() => runApp(LoGin());

class LoGin extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: "登陆界面",
        debugShowCheckedModeBanner: false,
        theme: ThemeData(primarySwatch: Colors.blue),
        home: HomePage());
  }
}

class HomePage extends StatelessWidget {
  TextEditingController phonecontroller = new TextEditingController();
  TextEditingController passcontroller = new TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("登录界面"),
        centerTitle: true,
      ),
      body: Column(
        children: <Widget>[
          Container(
            padding: const EdgeInsets.only(top: 50),
            child: Center(
              child: Image.asset(
                'images/lake.jpg',
                width: 100,
                height: 100,
                alignment: Alignment.center,
                fit: BoxFit.cover,
              ),
            ),
          ),
          Padding(
            padding: EdgeInsets.fromLTRB(20, 0, 20, 15),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                Icon(Icons.people),
                Expanded(
                    child: Padding(
                  padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
                  child: TextField(
                    controller: phonecontroller,
                    decoration: InputDecoration(hintText: '请输入用户名'),
                  ),
                ))
              ],
            ),
          ),
          Padding(
            padding: EdgeInsets.fromLTRB(20, 0, 20, 15),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                Icon(Icons.lock),
                Expanded(
                    child: Padding(
                  padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
                  child: TextField(
                    controller: passcontroller,
                    obscureText: true,
                    decoration: InputDecoration(hintText: '请输入密码'),
                  ),
                ))
              ],
            ),
          ),
          Container(
            width: MediaQuery.of(context).size.width,
            height: 80,
            padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
            child: Card(
              elevation: 26,
              color: Colors.blue,
              child: FlatButton(
                  onPressed: this._login,
                  child: Padding(
                    padding: EdgeInsets.all(20),
                    child: Text(
                      "登录",
                      style: TextStyle(fontSize: 20, color: Colors.white),
                    ),
                  )),
            ),
          )
        ],
      ),
    );
  }

  void _login() {
    Fluttertoast.showToast(
        msg: phonecontroller.text, toastLength: Toast.LENGTH_SHORT);
  }
}
